package config_manager

import (
	"go_server/game_server/dataconfig/configpb"
	"go_server/zinx/zlog"
)

// 获取单个关卡的数据
func GetStcTableLevelChapter_SheetLevelChapterById(id int32) (configpb.StcTableLevelChapter_SheetLevelChapter_C81D4AC6, bool) {
	config, ok := tableLevelChapterSheetLevelChapter[id]
	if !ok {
		zlog.Errorf("GetStcTableLevelChapter_SheetLevelChapter Err!!! id: %d", id)
		return configpb.StcTableLevelChapter_SheetLevelChapter_C81D4AC6{}, false
	}

	return configpb.StcTableLevelChapter_SheetLevelChapter_C81D4AC6{
		Id:            config.Id,
		EntType:       config.EntType,
		Type:          config.Type,
		UnlockStar:    config.UnlockStar,
		UnlockBulidLv: config.UnlockBulidLv,
		UnlockLevel:   config.UnlockLevel,
		FirstReward:   config.FirstReward,
		SweepReward:   config.SweepReward,
		PowerCost:     config.PowerCost,
		StarNum:       config.StarNum,
		StarReward1:   config.StarReward1,
		StarReward2:   config.StarReward2,
		StarReward3:   config.StarReward3,
	}, true
}

// 获取全部关卡的数据
func GetStcTableLevelChapter_SheetLevelChapterList(eventType int32) map[int32]*configpb.StcTableLevelChapter_SheetLevelChapter_C81D4AC6 {
	allConfig := make(map[int32]*configpb.StcTableLevelChapter_SheetLevelChapter_C81D4AC6)

	if tableLevelChapterSheetLevelChapter != nil {
		for _, config := range tableLevelChapterSheetLevelChapter {
			if eventType == config.EntType { //根据 战斗场景 分组
				row := configpb.StcTableLevelChapter_SheetLevelChapter_C81D4AC6{
					Id:            config.Id,
					EntType:       config.EntType,
					Type:          config.Type,
					UnlockStar:    config.UnlockStar,
					UnlockBulidLv: config.UnlockBulidLv,
					UnlockLevel:   config.UnlockLevel,
					FirstReward:   config.FirstReward,
					SweepReward:   config.SweepReward,
					PowerCost:     config.PowerCost,
					StarNum:       config.StarNum,
					StarReward1:   config.StarReward1,
					StarReward2:   config.StarReward2,
					StarReward3:   config.StarReward3,
				}
				allConfig[config.Id] = &row
			}
		}
	}
	return allConfig
}
